function xbtn(obj, back_y) 
{
    $(obj).each(function ()
    {
        var this_event = null;
        $(this).addClass("xbtn").html($(this).html() + "<span class='xbtn_span_1'></span>");
        var xy;
        if ( $(this).css('background-position') == undefined) {
            xy = [$(this).css('background-position-x'), $(this).css('background-position-y')];
        }
        else {
            xy = $(this).css('background-position').split(' ');
        }
        $('.xbtn_span' , this).css(
        {
            'background-image' : $(this).css('background-image'), 'background-position' : xy[0] + ' ' + back_y 
        }).hover(function ()
        {
            var obj = this;
            function go() 
            {
                var v = $(obj).css('opacity') - 0 + 0.1;
                if ( v <= 1 && this_event == 'in') 
                {
                    if (v > 0.9) {
                        v = 1;
                    }
                    $(obj).css({
                        'opacity' : v, 'filter' : 'alpha(opacity=' + (v * 100) + ')' 
                    });
                    setTimeout(go, 50);
                }
            }
            this_event = 'in';
            go();
        },
        function ()
        {
            var obj = this;
            function go() 
            {
                var v = $(obj).css('opacity') - 0.1;
                if (v < 0.1) {
                    v = 0;
                }
                if ( v >= 0 && this_event == 'out') 
                {
                    $(obj).css({
                        'opacity' : v, 'filter' : 'alpha(opacity=' + (v * 100) + ')' 
                    });
                    setTimeout(go, 50);
                }
            }
            this_event = 'out';
            go();
        });
    });
}
$(function ()
{
	$(".case li:nth-child(3n)").css({"float":"right","margin-right":0});
    xbtn(".header .btn1,.header .btn2,.header .btn3,.header .btn4,.header .btn5", '-41px');
    xbtn(".out .btn1,.out .btn2,.out .btn3,.out .btn4,.out .btn5", '-93px');
    xbtn(".logo", '-48px');
    $(document).mousemove(function (e) 
    {
        var offset = $(document).width() / 2 - e.clientX;
        $(".banner").css({
            "background-position" : ( ($(document).width() - 1600) / 2 + offset / 4 - 100 ) + "px 0px"
        });
    });
    function foot_scroll() 
    {
        if ($(document).scrollTop() < ($(document).height() - $(window).height()) * 0.7 ) 
        {
            $('.footer').animate({
                'bottom' : '-278px'
            },
            800, function ()
            {
                setTimeout(foot_scroll, 500);
            });
        }
        else 
        {
            $('.footer').animate({
                'bottom' : '0px'
            },
            800, function ()
            {
                setTimeout(foot_scroll, 500);
            });
        }
    }
    foot_scroll();
});